package com.haoshuang.zhouzhoubang.ui.page.settled.upload

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData
import kotlinx.coroutines.flow.MutableStateFlow

class UploadBusinessLicenseViewModel : BaseViewModel() {

    /**
     * 上传营业执照
     */
    val uploadStoreLicenseData = StatefulMutableLiveData<ResponseBean<Any>>()
    fun uploadStoreLicense(business_license: String?) = netRequest {
        start { uploadStoreLicenseData.value = StateData.Loading }
        request { ApiRepo.uploadBusinessLicense(business_license)  }
        success { uploadStoreLicenseData.value = StateData.Success(it) }
        error { code, msg ->
            uploadStoreLicenseData.value = StateData.Error(code, msg)
        }
    }

}